<template>
  <div>
    <img src="@/assets/images/logo.png" alt="" class="logo" />
    <div class="nav">
      <div :class="{ active: Comp === 'Home' }" @click="chanageNav">
        国内疫情
      </div>
      <div :class="{ active: Comp === 'Guowai' }" @click="chanageNav">
        海外疫情
      </div>
    </div>
    <keep-alive>
      <component :is="Comp"></component>
    </keep-alive>
  </div>
</template>

<script>
import Home from "@/views/Home/Home.vue";
import Guowai from "@/views/Guowai/index.vue";
export default {
  data() {
    return {
      Comp: "Home",
    };
  },
  components: {
    Home,
    Guowai,
  },
  methods: {
    chanageNav() {
      this.Comp = this.Comp === "Home" ? "Guowai" : "Home";
    },
  },
};
</script>

<style scoped lang="scss">
.logo {
  width: 100%;
}
.nav {
  display: flex;
  justify-content: space-around;
  position: relative;
  border-radius: 0.2rem 0.2rem 0 0;
  z-index: 1;
  margin-top: -0.2rem;
  background-color: #fff;
  > div {
    margin-top: 0.2rem;
    font-size: 0.3rem;
  }
  .active {
    color: #3343ff;
  }
}
</style>